<% content_for :css do %>
  <%= stylesheet_link_tag 'helps_index','helps_open_api' %>
<% end %>
<div id='content'>
  <%= render :file => 'helps/_left.html' %>
  <div id="main" class="prepend-5 span-19">
    <div id="main_c" class="px14">
      <h1><%= image_tag 'helps/open_api.gif', :alt => 'OpenApi', :title => 'OpenApi', :size => '360x48' %></h1>
      <!-- Qlist -->
      <ol style="margin-left: 3em; line-height: 180%; margin-top: 0pt;" start="1">
        <!-- 38 -->
        <li>
          <a tabindex="2" href="#a1" onclick="Effect.ScrollTo('q1',{duration:2.0});Effect.Pulsate('q1_t',{duration:6.0}); return false;">
            飞信短信发送接口
          </a>
        </li>   
      </ol>
      <hr>
      <h3 class='ps'>REST规范接口 </h3>
      <div class='ps'>
        <p>
          麦吐司网开放平台API是采用REST基础的接口规范。所有的麦吐司网(<%= link_to 'http://mytusi.com','http://mytusi.com', :target => :_blank, :title => 'http://mytusi.com' %>) 开放平台API都是通过HTTP POST向XN API REST Server(<%= link_to 'http://www.mytusi.com/open_api','http://www.mytusi.com/open_api', :title => 'http://www.mytusi.com/open_api', :target=>:_blank %>) 发送请求来实现的。几乎所有的计算机语言都可以通过HTTP协议同REST服务器通信。
        </p>
        <p>
          <b>特别注意:</b>在向麦吐司网REST Api服务器发送POST请求时，会传入很多参数，格式为key=value，<b class='h'>必须对value进行URL编码（UTF-8）</b>才能正确调用。
        </p>
      </div>
      <!-- Alist -->
      <p id="q1">
        <a name="a1"></a>
      </p><h3 id="q1_t">1.飞信短信发送接口 </h3>
      <div class="l16">
        <p class='h1'>前提条件：</p>        
        <div class='requested'>
          <p>
            1. 必须已经<%= link_to '注册成为麦吐司的会员', new_user_url, :target => :_blank, :title => '注册成为麦吐司的会员'  %>
          </p>
          <p>
            2. 必须<%= link_to '绑定麦吐司机器人', edit_user_url(:id => :current, :target=>:mobile), :target => :_blank, :title => '绑定麦吐司机器人'  %>（目前暂时只支持飞信）
            <%= image_tag 'helps/open_api/binded_fetion.jpg', :id => :binded_fetion %>
          </p>
        </div>        
        <p class='h1'>发送格式</p>
        <div class='code'>  
          <dl>
            <dt>URL:<dt>
            <dd>http://www.mytusi.com/open_api/sms</dd>
          </dl>
          <dl>
            <dt>Method:<dt>
            <dd>POST</dd>
          </dl>
        </div>
        <div class='code'>  
          <dl class='title'>
            <dt>key<dt>
            <dd>Description</dd>
          </dl>
          <dl>
            <dt>mobile:<dt>
            <dd>手机号</dd>
          </dl>
          <dl>
            <dt>password:<dt>
            <dd>在麦吐司网设置的登录密码，明文</dd>
          </dl>
          <dl>
            <dt>message:<dt>
            <dd>短信内容</dd>
          </dl>
        </div>        
      </div>
      <p class='h1'>返回结果-<b class='s'>成功</b></p>
      <div class='result'>
        <p class='c'><%= h "<?xml version='1.0' encoding='UTF-8'?>" %></p>
        <p class='l1'><%= h "<result>SUCCESS</result>" %></p>
      </div>
      <p class='h1'>返回结果-<b>失败</b>-<b class='c'>无此用户</b></p>
      <div class='result'>
        <p class='c'><%= h "<?xml version='1.0' encoding='UTF-8'?>" %></p>
        <p class='l1'><%= h "<errors>" %></p>
        <p class='l2'><%= h "<error>USER_INVALID</error>" %></p>
        <p class='l1'><%= h "</errors>" %></p>
      </div>
      <p class='h1'>返回结果-<b>失败</b>-<b class='c'>密码错误</b></p>      
      <div class='result'>
        <p class='c'><%= h "<?xml version='1.0' encoding='UTF-8'?>" %></p>
        <p class='l1'><%= h "<errors>" %></p>
        <p class='l2'><%= h "<error>PASSWORD_ERROR</error>" %></p>
        <p class='l1'><%= h "</errors>" %></p>
      </div>
      <p class='h1'>返回结果-<b>失败</b>-<b class='c'>未绑定机器人</b></p>      
      <div class='result'>
        <p class='c'><%= h "<?xml version='1.0' encoding='UTF-8'?>" %></p>
        <p class='l1'><%= h "<errors>" %></p>
        <p class='l2'><%= h "<error>NO_ROBOT</error>" %></p>
        <p class='l1'><%= h "</errors>" %></p>
      </div>
      <p class='h1'>返回结果-<b>失败</b>-<b class='c'>服务器端出现故障，稍候重试</b></p>      
      <div class='result'>
        <p class='c'><%= h "<?xml version='1.0' encoding='UTF-8'?>" %></p>
        <p class='l1'><%= h "<errors>" %></p>
        <p class='l2'><%= h "<error>REQUEST_FAILED</error>" %></p>
        <p class='l1'><%= h "</errors>" %></p>
      </div>
      <p class='h1'>返回结果-<b>失败</b>-<b class='c'>手机已欠费</b></p>      
      <div class='result'>
        <p class='c'><%= h "<?xml version='1.0' encoding='UTF-8'?>" %></p>
        <p class='l1'><%= h "<errors>" %></p>
        <p class='l2'><%= h "<error>USER_SUSPEND</error>" %></p>
        <p class='l1'><%= h "</errors>" %></p>
      </div>
      <p class='h1'>样例</p>      
      <div class='example'>
        <%= render :file => 'open_api/sms/new.html' %>
      </div>
      <div class="go_to_top"><a class="px11" href="#top" onclick="Effect.ScrollTo('top'); return false;">» 返回顶部</a></div>
      <hr size="1">
    </div>
  </div>
</div>  
<% if @id %>
  <script type="text/javascript" charset="utf-8">
    Effect.ScrollTo('q<%= @id %>',{duration:2.0});
    Effect.Pulsate('q<%= @id %>_t',{duration:6.0});
  </script>
<% end %>